C     ==================================================================  
      SUBROUTINE WrtTab(ROWNUM, COLNUM, TABLE, OPT)
      INTEGER ROWNUM, COLNUM, OPT
      REAL*8 TABLE(ROWNUM,COLNUM)
#include "ppexec_user.cmn"
      INTEGER I, J
      CHARACTER*8 FORCHR(0:COLNUM+1), FBIG, FMED, FSML
      DATA FBIG, FMED, FSML /'ES13.3, ', 'F13.4, ', 'E13.3, '/ 
      IF (OPT .EQ. 0) THEN
        WRITE(USER_NHSTRY, *) '>>>>>> DEBUGING <<<<<<'
      END IF
      FORCHR(0) = '('     
      FORCHR(COLNUM+1) = ')'
      DO I=1,ROWNUM  
        DO J=1,COLNUM    
          IF (TABLE(I,J) .GE. 1000.) THEN
            FORCHR(J) = FBIG    
          ELSE IF ((TABLE(I,J) .GT. 0.001) .OR. 
     +             (TABLE(I,J) .EQ. 0.0)) THEN
            FORCHR(J) = FMED    
          ELSE      
            FORCHR(J) = FSML    
          END IF
        END DO  
        WRITE(USER_NHSTRY, FORCHR) (TABLE(I,J), J = 1, COLNUM)
      END DO
      END

      
C     ==================================================================       
      SUBROUTINE WrtHis(INPTXT, N, VALUE, OPT)
      CHARACTER*(*) INPTXT
      REAL*8 VALUE(*)
      INTEGER N, OPT, I
#include "ppexec_user.cmn"
      IF (OPT .EQ. 0) THEN
        WRITE(USER_NHSTRY, *) '>>>>>> DEBUGING <<<<<<'
      END IF
      IF (N .EQ. 0) THEN
        WRITE(USER_NHSTRY, *) INPTXT
      ELSE IF (N .LT. 2) THEN
        WRITE(USER_NHSTRY, *) INPTXT, VALUE(1)
      ELSE
        WRITE(USER_NHSTRY, *) INPTXT, (VALUE(I), I = 1, N)
      END IF
      RETURN
      END
      
      
C     ==================================================================       
      SUBROUTINE Wrt1DArray(FILENAME, N, ARRAY)
      CHARACTER*12 FILENAME
      REAL*8 ARRAY(N)
      
      INTEGER*4 N, I
           
      OPEN(UNIT = 1, FILE = FILENAME)
      
      DO I = 1, N
        WRITE(1, 1000) ARRAY(I)
      END DO
      
      CLOSE(UNIT = 1, STATUS = 'SAVE')
      
 1000 FORMAT(E12.4)
      
      RETURN
      
      END SUBROUTINE
      
      
C     ==================================================================       
      SUBROUTINE Wrt2DArray(FILENAME, N, M, ARRAY)
      CHARACTER*12 FILENAME
      INTEGER*4 N, M
      REAL*8 ARRAY(N,M)
      
      INTEGER*4 I, J
           
      OPEN(UNIT = 1, FILE = FILENAME)
      
      DO I = 1,  N
        WRITE(1, 1000) (ARRAY(I,J), J = 1, M)
      END DO

      CLOSE(UNIT = 1, STATUS = 'SAVE')
      
 1000 FORMAT(<M>E12.4)
 
      RETURN
            
      END SUBROUTINE
      

C     ==================================================================       
      SUBROUTINE WrtGeoParas()
      USE DCMD_CMOD
      INTEGER*4 I
      REAL*8 TABLE(2,4)
      
      DO I = 1, 2
        TABLE(I,1) = COM_ID(I)
        TABLE(I,2) = COM_OD(I)
        TABLE(I,3) = COM_DEQ(I)
        TABLE(I,4) = COM_CSA(I)
      END DO
      
      CALL Wrt2DArray('GeoParas.dat', 2, 4, TABLE)
      
      END SUBROUTINE
      
      
C     ==================================================================       
      SUBROUTINE WrtMemProps()
      USE DCMD_CMOD
      REAL*8 TABLE(6)
      
      TABLE(1) = DBLE(COM_NUM)
      TABLE(2) = COM_LEN
      TABLE(3) = COM_THK
      TABLE(4) = COM_ALOC
      TABLE(5) = COM_PERM
      TABLE(6) = COM_COND
      
      CALL Wrt1DArray('MemProps.dat', 6, TABLE)
      
      END SUBROUTINE
      
      
C     ==================================================================       
      SUBROUTINE WrtStmProps()
      USE DCMD_CMOD
      INTEGER*4 I
      REAL*8 TABLE(2,4)
      
      DO I = 1, 2
        TABLE(I,1) = COM_RHO(I)
        TABLE(I,2) = COM_MU(I)
        TABLE(I,3) = COM_LAMBDA(I)
        TABLE(I,4) = COM_CP(I)
      END DO
      
      CALL Wrt2DArray('StmProps.dat', 2, 4, TABLE)
      
      END SUBROUTINE
      
C     ==================================================================       
      SUBROUTINE WrtComVars()
      USE DCMD_CMOD
      INTEGER*4 I
      REAL*8 TABLE(2,8)
      
      DO I = 1, 2
        TABLE(I,1) = COM_WIN(I)
        TABLE(I,2) = COM_TIN(I)
        TABLE(I,3) = COM_PIN(I)
        TABLE(I,4) = COM_WOUT(I)
        TABLE(I,5) = COM_TOUT(I)
        TABLE(I,6) = COM_POUT(I)
      END DO
      
      CALL Wrt2DArray('ComVars.dat', 2, 6, TABLE)
      
      END SUBROUTINE
      
